<template>
<el-container>
    <el-header>
      <el-menu
  :default-active="activeIndex2"
  class="el-menu-demo"
  mode="horizontal"
  @select="handleSelect"
  background-color="#545c64"
  text-color="#fff"
  active-text-color="#ffd04b">
  <el-menu-item index="1" class="fr">处理中心</el-menu-item>
  <el-submenu index="2" class="fr">
    <template slot="title">我的工作台</template>
    <el-menu-item index="2-1">选项1</el-menu-item>
    <el-menu-item index="2-2">选项2</el-menu-item>
    <el-menu-item index="2-3">选项3</el-menu-item>
    <el-submenu index="2-4">
      <template slot="title">选项4</template>
      <el-menu-item index="2-4-1">选项1</el-menu-item>
      <el-menu-item index="2-4-2">选项2</el-menu-item>
      <el-menu-item index="2-4-3">选项3</el-menu-item>
    </el-submenu>
  </el-submenu>
  <el-menu-item index="3" disabled class="fr">消息中心</el-menu-item>
  <el-menu-item index="4" class="fr"><a href="https://www.ele.me" target="_blank" >订单管理</a></el-menu-item>
      </el-menu >
    </el-header>
    <el-container>
      <el-aside width="200px">

<el-menu :default-active="$store.state.permisser.currentMenu" class="el-menu-vertical-demo"  background-color="#545c64"  text-color="#fff" active-text-color="#ffd04b" @open="handleOpen" @close="handleClose" :collapse="isCollapse" >
<sideMenu :menuList="sidebarMenu"></sideMenu>
</el-menu>
      </el-aside>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>
  </el-container>
</template>
<style>
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
</style>
<script>
  import sideMenu from "./menu/sideMenu";
    export default{
        name:"layout",
        components:{
          sideMenu
        },
        data() {
          return {
            activeIndex2: '1',
            isCollapse: false,
            sidebarMenu:[],
            currentMenu:""
          };
        },
        methods: {
          handleSelect(key, keyPath) {
           console.log(key);
          },
          handleOpen(key, keyPath) {
            console.log(key, keyPath);
          },
          handleClose(key, keyPath) {
            console.log(key, keyPath);
          }
        },
        created(){
          //初始化资源菜单，这里通过Vuex已经处理好了当前用户的资源有哪些。
          this.sidebarMenu = this.$store.state.permisser.sidebarMenu;
        }
    }
</script>
<style>
  .el-header{
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: blue;
    color: #333;
    text-align: center;
    line-height: 200px;

  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }

  .el-container{
  position: absolute; 
  width: 100%; 
  top: 0px ; 
  left: 0 ; 
  bottom: 0;
}
.el-header{
  padding: 0;
  z-index: 1000;
}
 
.el-header .fr{
  float: right;
}
.el-header .el-menu{
  border-bottom: none;
}
.el-aside, .el-main{
  padding-top: 60px;
}
.el-aside{
  background: #545c64;
}
.el-aside .el-menu{
  border-right: none;
}

</style>
